<template>
    <view :class="['container-scope', 'animated', 'bounceInDown', 'data-v-a4b511e0', isNavbarEnable ? 'with-navtar' : '']">
        <view class="content-scope data-v-a4b511e0" v-if="isNotOpen">
            <view class="title data-v-a4b511e0" style="margin-top: 300rpx">抢购用户太多了</view>
            <view class="title data-v-a4b511e0" style="margin-top: 20rpx">请不要离开此页面，等待几秒后刷新哦~</view>
            <view class="bottom data-v-a4b511e0">
                <view class="button-c data-v-a4b511e0">
                    <view @tap="__e" class="btn confirm bg-purple data-v-a4b511e0" :data-event-opts="[['tap', [['handleRefresh', ['$event']]]]]">立即刷新</view>
                </view>
            </view>
        </view>
        <view class="content-scope data-v-a4b511e0" v-else>
            <view class="title data-v-a4b511e0" v-if="isOpen">恭喜您获得</view>
            <view :class="['unopen-c', 'data-v-a4b511e0', boxImgMode]" v-if="!isOpen">
                <view :class="['unopen', 'data-v-a4b511e0', status === 0 ? 'a0' : '', status === 1 ? 'a1' : '']">
                    <image class="data-v-a4b511e0" mode="aspectFit" :src="boxImg || defaultBoxImage"></image>
                </view>
            </view>
            <scroll-view class="scroll-view-212 data-v-a4b511e0" :scrollY="true" v-else>
                <view class="sku-list data-v-a4b511e0">
                    <view
                        @tap="__e"
                        :class="['item', 'data-v-a4b511e0', 'item-' + item.g0]"
                        :data-event-opts="[['tap', [['checkSku', ['$0'], [[['skus', '', index]]]]]]]"
                        v-for="(item, index) in $root.l0"
                        :key="index"
                    >
                        <view class="thumb-c data-v-a4b511e0">
                            <image class="thumb data-v-a4b511e0" mode="aspectFit" :src="item[$orig].thumb"></image>
                            <view class="title data-v-a4b511e0">{{ item[$orig].title }}</view>
                            <view class="total data-v-a4b511e0">{{ '×' + item[$orig].total }}</view>
                        </view>
                    </view>
                </view>
            </scroll-view>
            <view @tap="__e" class="lottery-tips data-v-a4b511e0" :data-event-opts="[['tap', [['goJikaDetail', ['$event']]]]]" v-if="showResult && rewardJikaTimes">
                <text class="data-v-a4b511e0">恭喜您额外获得</text>
                <text class="ticket-total data-v-a4b511e0">{{ rewardJikaTimes.total }}</text>
                <text class="data-v-a4b511e0">次集卡机会</text>
                <text class="new-iconfont icon-arrow-right data-v-a4b511e0"></text>
            </view>
            <block v-else>
                <view @tap="__e" class="lottery-tips data-v-a4b511e0" :data-event-opts="[['tap', [['goLotteryDetail', ['$event']]]]]" v-if="showResult && rewardLotteryTicket">
                    <text class="data-v-a4b511e0">恭喜您额外获得</text>
                    <text class="ticket-total data-v-a4b511e0">{{ rewardLotteryTicket.total }}</text>
                    <text class="data-v-a4b511e0">张活动抽奖码</text>
                    <text class="new-iconfont icon-arrow-right data-v-a4b511e0"></text>
                </view>
            </block>
            <view class="bottom data-v-a4b511e0" v-if="showResult">
                <view class="button-c data-v-a4b511e0" v-if="isReturnSaleSuccess">
                    <view @tap="__e" class="btn confirm bg-purple data-v-a4b511e0" :data-event-opts="[['tap', [['goBack', ['$event']]]]]">再抽一个</view>
                    <view class="btn return-sale bg-white data-v-a4b511e0">已返售</view>
                </view>
                <block v-else>
                    <view class="button-c data-v-a4b511e0" v-if="tryMode">
                        <view @tap="__e" class="btn confirm bg-purple data-v-a4b511e0" :data-event-opts="[['tap', [['goBack', ['$event']]]]]">试玩不发货哦~</view>
                    </view>
                    <view class="button-c data-v-a4b511e0" v-else>
                        <view @tap="__e" class="btn confirm bg-purple data-v-a4b511e0" :data-event-opts="[['tap', [['handleOk', ['$event']]]]]">
                            {{ '' + (buttonTitle || '去发货') + '' }}
                        </view>
                        <view @tap="__e" class="btn return-sale data-v-a4b511e0" :data-event-opts="[['tap', [['returnSale', ['$event']]]]]" v-if="!orderConfig.is_ban_return_sale">
                            查看
                        </view>
                    </view>
                </block>
            </view>
            <view @tap="__e" class="close-btn data-v-a4b511e0" :data-event-opts="[['tap', [['close', ['$event']]]]]" v-if="showResult">
                <text class="new-iconfont icon-close data-v-a4b511e0"></text>
            </view>
        </view>
        <return-sale-popup
            @__l="
                __l($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['e1']]]
                    ]
                })
            "
            @cancel="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['e1']]]
                    ]
                })
            "
            @refresh="
                __e($event, {
                    eventOpts: [
                        ['^cancel', [['e0']]],
                        ['^refresh', [['e1']]]
                    ]
                })
            "
            class="data-v-a4b511e0"
            :data-event-opts="[
                ['^cancel', [['e0']]],
                ['^refresh', [['e1']]]
            ]"
            :uuid="orderUuid"
            vueId="5436f222-1"
            v-if="isShowReturnSale"
        ></return-sale-popup>
    </view>
</template>

<script>
import returnSalePopup from '@/components/ReturnSalePopup/ReturnSalePopup';
import tabBar from '@/components/TabBar/tabBar';
(global.webpackJsonp = global.webpackJsonp || []).push([
    ['components/OpenBoxPopup/OpenBoxPopup'],
    {
        '58de': function (t, e, n) {
            'use strict';

            n.d(e, 'b', function () {
                return i;
            });
            n.d(e, 'c', function () {
                return a;
            });
            n.d(e, 'a', function () {
                return o;
            });
            var o = {
                ReturnSalePopup: function () {
                    return n.e('components/ReturnSalePopup/ReturnSalePopup').then(n.bind(null, 'f4ef'));
                }
            };
            var i = function () {
                var that = this;
                var e =
                    (that.$createElement,
                    that._self._c,
                    !that.isNotOpen && that.isOpen
                        ? that.__map(that.skus, function (e, n) {
                              return {
                                  $orig: that.__get_orig(e),
                                  g0: that.skus.length
                              };
                          })
                        : null);
                that._isMounted ||
                    ((that.e0 = function (e) {
                        that.isShowReturnSale = false;
                    }),
                    (that.e1 = function (e) {
                        that.isReturnSaleSuccess = true;
                    }));
                that.$mp.data = Object.assign(
                    {},
                    {
                        $root: {
                            l0: e
                        }
                    }
                );
            };
            var a = [];
        },
        '78a1': function (t, e, n) {
            'use strict';

            n.r(e);
            var o = n('870e');
            var i = n.n(o);
            for (var a in o) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return o[t];
                        });
                    })(a);
                }
            }
            e.default = i.a;
        },
        '870e': function (t, e, n) {
            'use strict';

            (function (t) {
                Object.defineProperty(e, '__esModule', {
                    value: true
                });
                e.default = void 0;
                var n = {
                    props: {
                        boxImg: String,
                        boxImgMode: String,
                        buttonTitle: String,
                        order: Object,
                        tryMode: Boolean,
                        tryInfo: Object,
                        isNavbarEnable: false,
                        config: Object
                    },
                    data: function () {
                        return {
                            isOpen: false,
                            showResult: false,
                            status: 0,
                            isShowReturnSale: false,
                            isReturnSaleSuccess: false,
                            package: {},
                            defaultBoxImage: 'https://cdn2.hquesoft.com/box/openbox.png',
                            isNotOpen: false
                        };
                    },
                    mounted: function () {
                        this.initData();
                    },
                    computed: {
                        skus: function () {
                            return this.package.skus || [];
                        },
                        orderConfig: function () {
                            return this.$store.getters.setting.order;
                        },
                        rewardJikaTimes: function () {
                            return this.package.reward && this.package.reward.jika_times;
                        },
                        rewardLotteryTicket: function () {
                            return this.package.reward && this.package.reward.lottery_ticket;
                        }
                    },
                    methods: {
                        initData: function () {
                            var that = this;
                            this.tryMode
                                ? this.$http('/try/packages/'.concat(this.tryInfo.package_uuid)).then(function (e) {
                                      that.package = e.data;
                                      that.startOpenAnimate();
                                  })
                                : this.$http('/asset/package?order_id='.concat(this.order.id))
                                      .then(function (e) {
                                          that.package = e.data;
                                          that.startOpenAnimate();
                                      })
                                      .catch(function (e) {
                                          that.isNotOpen = true;
                                      });
                        },
                        startOpenAnimate: function () {
                            var that = this;
                            this.config && 'none' == this.config.animation_mode
                                ? ((this.status = 1),
                                  setTimeout(function () {
                                      that.isOpen = true;
                                      that.$playAudio('open');
                                      setTimeout(function () {
                                          that.showResult = true;
                                      }, 800);
                                  }, 400))
                                : (setTimeout(function () {}, 500),
                                  setTimeout(function () {
                                      that.status = 1;
                                      setTimeout(function () {
                                          that.isOpen = true;
                                          that.$playAudio('open');
                                          setTimeout(function () {
                                              that.showResult = true;
                                          }, 1100);
                                      }, 400);
                                  }, 2500));
                        },
                        handleRefresh: function () {
                            this.isNotOpen = false;
                            this.initData();
                        },
                        goLotteryDetail: function () {
                            t.navigateTo({
                                url: '/pages/lottery/detail?uuid=' + this.rewardLotteryTicket.uuid
                            });
                        },
                        goJikaDetail: function () {
                            t.navigateTo({
                                url: '/pages/jika/detail?uuid=' + this.rewardJikaTimes.uuid
                            });
                        },
                        returnSale: function () {
                            t.navigateTo({
                                url: '/pages/myBox/index'
                            });
                        },
                        handleOk: function () {
                            t.redirectTo({
                                url: '/pages/myBox/index'
                            });
                        },
                        goBack: function () {
                            t.navigateBack({
                                delta: 1
                            });
                        },
                        close: function () {
                            this.$emit('close');
                            this.$emit('refresh');
                        },
                        checkSku: function (e) {
                            'score' === e.sku_type
                                ? t.navigateTo({
                                      url: '/pages/myScore/index'
                                  })
                                : 'coupon' === e.sku_type
                                ? t.navigateTo({
                                      url: '/pages/myCoupons/index'
                                  })
                                : 'redpack' === e.sku_type
                                ? t.navigateTo({
                                      url: '/pages/myRedpack/index'
                                  })
                                : console.log(e);
                        }
                    }
                };
                e.default = n;
            }.call(this, n('543d').default));
        },
        '8fdc': function (t, e, n) {},
        '9fe0': function (t, e, n) {
            'use strict';

            n.r(e);
            var o = n('58de');
            var i = n('78a1');
            for (var a in i) {
                if (['default'].indexOf(a) < 0) {
                    (function (t) {
                        n.d(e, t, function () {
                            return i[t];
                        });
                    })(a);
                }
            }
            n('ada2');
            var u = n('f0c5');
            var s = Object(u.a)(i.default, o.b, o.c, false, null, 'a4b511e0', null, false, o.a, void 0);
            e.default = s.exports;
        },
        ada2: function (t, e, n) {
            'use strict';

            var o = n('8fdc');
            n.n(o).a;
        }
    }
]);
(global.webpackJsonp = global.webpackJsonp || []).push([
    'components/OpenBoxPopup/OpenBoxPopup-create-component',
    {
        'components/OpenBoxPopup/OpenBoxPopup-create-component': function (t, e, n) {
            n('543d').createComponent(n('9fe0'));
        }
    },
    [['components/OpenBoxPopup/OpenBoxPopup-create-component']]
]);
</script>
<style>
@import './OpenBoxPopup.css';
</style>
